{extend name="public/base"}
{block name='main'}

<!-- 广告 -->
<div class="layui-container mb20">
  <div class="banner-wrap"><!--矩形广告位-->
  </div>
</div>
<!-- 广告 end-->
<!-- 主体开始 -->
<div class="layui-container fly-marginTop">
  <div class="fly-panel fly-panel-user" pad20="">
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title">
        <li><a href="{:url('user/login')}">登入</a></li>
        <li class="layui-this">注册</li>
      </ul>
      <div class="layui-form layui-tab-content" style="padding: 20px 0; min-height:500px">
        <div class="layui-tab-item layui-show">
          <div class="layui-form layui-form-pane">
            <form class="layui-form" method="post">
              <input type="hidden" class="ins" name="iscaptcha" value="1">
              <input type="hidden" name="refer" value="">
              <input type="hidden" name="ret_url" value="{:url('user/login')}">
              <div class="layui-form-item">
                <label for="email" class="layui-form-label">用户名/邮箱</label>
                <div class="layui-input-inline">
                  <input type="text" class="layui-input" placeholder="请输入用户名" name="username">
                </div>
              </div>
              <div class="layui-form-item">
                <label for="pass" class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                  <input type="text" class="layui-input" placeholder="请输入邮箱" name="email">
                </div>
              </div>
              <div class="layui-form-item">
                <label for="pass" class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                  <input type="password" class="layui-input" placeholder="请输入密码" name="password">
                </div>
              </div>
              <div class="layui-form-item">
                <label for="pass" class="layui-form-label">重复密码</label>
                <div class="layui-input-inline">
                  <input type="password" class="layui-input" placeholder="重复密码" name="repassword">
                </div>
              </div>

              <div class="layui-form-item">
                <label for="pass" class="layui-form-label">图形码</label>
                <div class="layui-input-inline">
                  <input name="captcha" type="number" placeholder="图形码验证码" class="layui-input" id="form-field-3" value="">
                </div>
                <div class="layui-form-mid" id="captcha_img" style="padding: 0!important;">
                  {:captcha_img()}
              </div>
              </div>
              <div class="layui-form-item">
                <button class="layui-btn" id="regbtn">提交注册</button>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script src="__PUBLIC__/theme/blueideal/layui/layui.js"></script>
<script src="__PUBLIC__/theme/blueideal/layui/particles.min.js"></script>
<script src="__PUBLIC__/theme/blueideal/layui/app.js"></script>
<script type="text/javascript">
  layui.use(['form', 'layer'], function () {
    // 操作对象
    var form = layui.form, layer = layui.layer, $ = layui.jquery;
    $('#regbtn').on('click',function(){
      var data = $("form").serialize();
      $.post("{:url('user/register')}",data,function(res){
        if(res.status ==  1){
          layer.msg(res.msg,{time:1800},function(){
            location.href = "{:url('ucenter/index')}";
          });
        }else{
          $("#captcha_img img").attr('src','{:captcha_src()}?tm='+Math.random());//刷新验证码
          layer.msg(res.msg,{time:1800});
        }
      });
      return false;
    });
  })
</script>
<!-- 主体结束 -->
<script>
  layui.config({
    version: "3.0.0"
    ,base: '__PUBLIC__/theme/blueideal/mods/' //这里实际使用时，建议改成绝对路径
  }).extend({
    fly: 'index'
  }).use('fly');
</script>
{/block}